package com.ruoyi.web.controller.starbucks;
import java.util.List;

import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.starbucks.domain.StarbucksCards;
import com.ruoyi.starbucks.service.IStarbucksCardsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 星巴克卡包表Controller
 *
 * @author ruoyi
 * @date 2021-01-08
 */
@ApiOperation("星巴克卡包")
@RestController
@RequestMapping("/starbucks/cards")
public class StarbucksCardsController extends BaseController
{
    @Autowired
    private IStarbucksCardsService starbucksCardsService;

    /**
     * 查询星巴克卡包表列表
     */
    @ApiOperation("查询星巴克卡包表列表")
    @PreAuthorize("@ss.hasPermi('starbucks:cards:list')")
    @GetMapping("/list")
    public TableDataInfo list(StarbucksCards starbucksCards)
    {
        startPage();
        List<StarbucksCards> list = starbucksCardsService.selectStarbucksCardsList(starbucksCards);
        return getDataTable(list);
    }

    /**
     * 导出星巴克卡包表列表
     */
    @PreAuthorize("@ss.hasPermi('starbucks:cards:export')")
    @Log(title = "星巴克卡包表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StarbucksCards starbucksCards)
    {
        List<StarbucksCards> list = starbucksCardsService.selectStarbucksCardsList(starbucksCards);
        ExcelUtil<StarbucksCards> util = new ExcelUtil<StarbucksCards>(StarbucksCards.class);
        return util.exportExcel(list, "cards");
    }

    /**
     * 获取星巴克卡包表详细信息
     */
    @ApiOperation("获取星巴克卡包表详细信息")
    @PreAuthorize("@ss.hasPermi('starbucks:cards:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(starbucksCardsService.selectStarbucksCardsById(id));
    }

    /**
     * 新增星巴克卡包表
     */
    @PreAuthorize("@ss.hasPermi('starbucks:cards:add')")
    @Log(title = "星巴克卡包表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StarbucksCards starbucksCards)
    {
        return toAjax(starbucksCardsService.insertStarbucksCards(starbucksCards));
    }

    /**
     * 修改星巴克卡包表
     */
    @PreAuthorize("@ss.hasPermi('starbucks:cards:edit')")
    @Log(title = "星巴克卡包表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StarbucksCards starbucksCards)
    {
        return toAjax(starbucksCardsService.updateStarbucksCards(starbucksCards));
    }

    /**
     * 删除星巴克卡包表
     */
    @PreAuthorize("@ss.hasPermi('starbucks:cards:remove')")
    @Log(title = "星巴克卡包表", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(starbucksCardsService.deleteStarbucksCardsByIds(ids));
    }
}
